package com.woniuxy.service.impl;

import com.woniuxy.dao.RegisterMessageDao;
import com.woniuxy.entity.RegMessageAndPatient;
import com.woniuxy.entity.RegisterMessage;
import com.woniuxy.service.RegisterMessageService;
import org.apache.ibatis.annotations.Param;
import com.woniuxy.entity.PageBean;
import com.woniuxy.entity.RegisterMessage;
import com.woniuxy.service.RegisterMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author g2l
 * @create 2022-07-06 17:16
 */
@Service
public class RegisterMessageServiceImpl implements RegisterMessageService {

    @Autowired
    private RegisterMessageDao dao;
    @Autowired
    private RegisterMessageDao registerMessageDao;




    @Override
    public List<RegMessageAndPatient> selectRegMessageAndPatients(int pageIndex, int pageSize) {
        return dao.selectRegMessageAndPatients(pageIndex,pageSize);
    }

    @Override
    public Integer selectRegMessageAndPatientsCount() {
        return dao.selectRegMessageAndPatientsCount();
    }

    @Override
    public List<RegMessageAndPatient> selectRegMessageAndPatientsByPatientName(int pageIndex, int pageSize, String patientName) {
        return dao.selectRegMessageAndPatientsByPatientName(pageIndex,pageSize,patientName);
    }

    @Override
    public Integer selectCountByPatientName(int pageSize, String patientName) {
        return dao.selectCountByPatientName(pageSize,patientName);
    }

    @Override
    public List<RegMessageAndPatient> selectRegMessageAndPatientsByDoctorName(int pageIndex, int pageSize, String doctorName) {
        return dao.selectRegMessageAndPatientsByDoctorName(pageIndex,pageSize,doctorName);
    }

    @Override
    public Integer selectCountByDoctorName(int pageSize, String doctorName) {
        return dao.selectCountByDoctorName(pageSize,doctorName);
    }

    @Override
    public PageBean<RegisterMessage> getAllRegisterMessage(RegisterMessage registerMessage, int pageIndex, int pageSize) {

        List<RegisterMessage> registerMessages =
                registerMessageDao.
                        selectRegisterMessageByCondition(registerMessage, pageIndex, pageSize);
        PageBean<RegisterMessage> pageBean = new PageBean<>();
        pageBean.setBeanList(registerMessages);
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        int taotalRecord = registerMessageDao.getRegisterMessageByConditionNum(registerMessage);
        pageBean.setTotalRecord(taotalRecord);
        return pageBean;
    }

    @Override
    public void modifyRegisterMessage(RegisterMessage registerMessage) {
        registerMessageDao.updateRegisterMessageById(registerMessage);
    }

    @Override
    public int insertRegisterMessage(RegisterMessage registerMessage) {
        return registerMessageDao.insertRegisterMessage(registerMessage);
    }
}
